package com.dubbo.lian.cms.modules.app.mq.queue;
 import com.dubbo.lian.cms.modules.app.Checkcode;
import com.dubbo.lian.cms.modules.app.mq.Email;
import org.apache.activemq.command.ActiveMQObjectMessage;
import org.springframework.transaction.annotation.Transactional;
 import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
 public class QueueConsumer2 implements MessageListener {
     /**
     * 163邮箱
     * @param m
     */
    @Override
    @Transactional
    public void onMessage(Message m) {
        System.out.println();
        ActiveMQObjectMessage om = (ActiveMQObjectMessage) m;
        try {
            Email email= (Email) om.getObject();
            Checkcode checkcode = new Checkcode();
            checkcode.setPhonenumber(email.getAddress());
            checkcode.setIsuse(0);
            checkcode.setCheckcode(email.getContent());
            try {
                checkcode.insert();
            } catch (Exception e) {
                e.printStackTrace();
            }
            QueueConsumer1.sendMail(email.getAddress(),email.getTitle(),email.getContent());
         } catch (JMSException e) {
            e.printStackTrace();
            throw new RuntimeException("Error");
        }
    }
 }
